import 'package:flutter/material.dart';
import '../../../../utils/base.dart';
import '../../../../widgets/tabs.dart';

class IconListItem extends StatelessWidget {
  final String icon;
  final String title;
  final String subtitle;
  final String time;
  final String rightText;
  final Color rightTextColor;
  final Color rightBackgroundColor;

  const IconListItem({
    Key key,
    this.icon,
    this.title,
    this.subtitle,
    this.time,
    this.rightText,
    this.rightTextColor,
    this.rightBackgroundColor,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Widget _left = Row(
      children: <Widget>[
        ClipRect(
          child: FadeInImage.assetNetwork(
            placeholder: "assets/logo.png", //预览图
            fit: BoxFit.cover,
            image: icon,
            width: Design.px(160),
            height: Design.px(160),
          ),
        ),
        Expanded(
          child: Container(
            padding: EdgeInsets.only(left: Design.px(30)),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(bottom: Design.px(45)),
                  child: Text(
                    title,
                    style: TextStyle(
                      color: HexColor('333333'),
                      fontSize: Design.px(38),
                      decoration: TextDecoration.none,
                      height: 1,
                    ),
                  ),
                ),
                Text(
                  '${subtitle}\n${time}',
                  style: TextStyle(
                    color: HexColor('666666'),
                    fontSize: Design.px(22),
                    decoration: TextDecoration.none,
                    height: 1.2,
                  ),
                ),
              ],
            ),
          ),
        )
      ],
    );

    Widget _right = Container(
      height: Design.px(42),
      width: Design.px(100),
      alignment: Alignment.center,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(Design.px(42))),
        border: Border.all(width: Design.px(1), color:rightTextColor),
        color: rightBackgroundColor,
      ),
      child: Text(
        rightText,
        style: TextStyle(
          color: rightTextColor,
          decoration: TextDecoration.none,
          fontSize: Design.px(24),
        ),
      ),
    );

    return Container(
      padding: EdgeInsets.symmetric(
        vertical: Design.px(25),
        horizontal: Design.px(60),
      ),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: Design.px(1),
            color: HexColor('cccccc'),
          ),
        ),
      ),
      child: Row(
        children: <Widget>[
          Expanded(
            child: _left,
          ),
          _right,
        ],
      ),
    );
  }
}
